using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.Operations.Queries;

/// <summary>
/// 工序查询命令。
/// </summary>
public record GetOperationListQuery(long LineId) : IRequest<IResult<List<ProcOperationDto>>>;

internal sealed class GetOperationListQueryHandler(IRepository<ProcOperation> repo) : IRequestHandler<GetOperationListQuery, IResult<List<ProcOperationDto>>>
{
    public async Task<IResult<List<ProcOperationDto>>> Handle(GetOperationListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(m => m.LineId == request.LineId, m => m.Order, false, cancellationToken);
        return Result.From(items.Adapt<List<ProcOperationDto>>());
    }
}
